'use strict';

angular.module('app')
  .service("svcMain", function($http, $q, $rootScope, $filter, server) {

    this.getLoginDetails = function() {
        var deferred = $q.defer();
        $http.get(server + '/member/get-login', {withCredentials: true})
            .success(function(data, status) {
                deferred.resolve(data);
            })
            .error(function(data, status) {
                deferred.reject(data);
            });

        return deferred.promise;
    };

    this.logout = function() {
        var deferred = $q.defer();
        $http.get(server + '/member/logout', {withCredentials: true})
            .success(function(data, status) {
                deferred.resolve(data);
            })
            .error(function(data, status) {
                deferred.reject(data);
            });

        return deferred.promise;
    };

    this.quickSearch = function(searchStr) {
        var deferred = $q.defer();
        $http.get(server + '/member/quick-search?searchStr=' + searchStr, {withCredentials: true})
            .success(function(data, status) {
                deferred.resolve(data);
            })
            .error(function(data, status) {
                deferred.reject(data);
            });

        return deferred.promise;
    };

    this.detailedInfo = function(memberId) {
        var deferred = $q.defer();
        $http.get(server + '/member/detailed-info?memberId=' + memberId, {withCredentials: true})
            .success(function(data, status) {
                deferred.resolve(data);
            })
            .error(function(data, status) {
                deferred.reject(data);
            });

        return deferred.promise;
    };

    })

;